def extend_euclid(a,b):
    global x
    global y
    if(b==0):
        x=1
        y=0
        #print("d:{0} x:{1} y:{2}".format(a,x,y))
        return (a,x,y)
    else:
        d=extend_euclid(b,a%b)[0]
        tmp=x
        x=y
        y=tmp-(a/b)*y
        #print("d:{0} x:{1} y:{2}".format(d,x,y))
        return (d,x,y)

def modular_linear_equation_solver(a,b,n):
    # t is (d,x,y)
    t=extend_euclid(a,n)
    print(t)
    d=t[0]
    x=t[1]
    y=t[2]
    if(b%d==0):
        x0=x*(b/d)%n
        for i in range(0,d):
            print((x0+i*(n/d))%n)
    else:
        print("no solutions")

if __name__=="__main__":
    #31.4.1  solution
    modular_linear_equation_solver(35,10,50)
